module.exports = (path, cb) => {
    const fs = require('fs');

        let buildDirExist = false;

        function checkBuildExist(){
            //监测编译文件是否存在
            fs.access(path, fs.constants.R_OK | fs.constants.W_OK, (err) => {
                console.log(err ? 'no access! you should compile your code first' : 'build files is found');
                if(!err){
                    buildDirExist = true;
                }else{
                    buildDirExist = false;
                }
            });
        }

        const checker = setInterval(()=>{
            if(buildDirExist){
                clearInterval(checker);
                return cb(path);
            }
            return checkBuildExist();
        },1000);
} 